﻿namespace Sidvall.AuthorizationManager.Model.DataPortalManagers
{
	public partial class AuthorizationScopeResourceItemManager<TEntity, TList>
	{
		#region Public Members

		#region GetItemAllIncludedAsync

		public async System.Threading.Tasks.Task<TList> GetItemsAllIncludedAsync(int? serverConnectionId, long authorizationScopeId, int? itemRowCount)
		{
			Sidvall.Data.FetchListCriteria<Data.Fields.AuthorizationScopeResourceItemField, Data.Relations.AuthorizationScopeResourceItemRelation> criteria;

			criteria = Sidvall.Data.CriteriaManager.NewFetchListCriteria<Data.Fields.AuthorizationScopeResourceItemField, Data.Relations.AuthorizationScopeResourceItemRelation>();
			criteria.IncludedEntities = new Sidvall.Data.RelationCollection<Data.Relations.AuthorizationScopeResourceItemRelation>();
			criteria.IncludedEntities.Add(Data.Relations.AuthorizationScopeResourceItemRelation.AuthorizationScopeResourceItemClaims);
			criteria.Filter = new Sidvall.Data.Filter<Data.Fields.AuthorizationScopeResourceItemField>();
			criteria.Filter.AddFilterItem(Data.Fields.AuthorizationScopeResourceItemField.AuthorizationScopeId, Sidvall.Data.ComparisonOperator.Equal, authorizationScopeId);
			criteria.SortItems = new Sidvall.Data.SortItemCollection<Data.Fields.AuthorizationScopeResourceItemField>();
			criteria.SortItems.Add(Data.Fields.AuthorizationScopeResourceItemField.Resource);
			criteria.SortItems.Add(Data.Fields.AuthorizationScopeResourceItemField.ResourceItemId);
			criteria.RowCount = itemRowCount;
			ParameterManager.InitializeParameters(criteria, serverConnectionId);

			return await GetItemsAsync(criteria).ConfigureAwait(false);
		}

		#endregion

		#endregion
	}
}